summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-07-14 10:31:41 +0200
committeraxis <qt-info@nokia.com>2009-07-14 15:06:25 +0200
commitfde7966c1b6122ed904d30e1f6e83eb8cd3a80b2 (patch)
treeae8ca630acfae0161ee27fe18c6fecb2c5d8bded
parent89e606a5663cc33bf0ee29e74dcc41459320344e (diff)
Fixed a consistency problem in the backing store.
Widgets maintain an internal state (inDirtyList) which says whether that widget is in the backing store's list of dirty widgets. Naturally this list has to be kept in sync with the actual list contents. This did not happen if the backing store was destroyed and recreated; if the list had any contents it would be destroyed without resetting the widget flags. Destroying and recreating the backing store is common on S60 where we try to save memory. Fixed by making sure those flags are reset during backing store destruction. Done together with Jason. RevBy: Jason Barron RevBy: bnilsen AutoTest: Included
-rw-r--r--src/gui/painting/qbackingstore.cpp4
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp29
2 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 34bc57820..405acb731 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -829,6 +829,10 @@ QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
QWidgetBackingStore::~QWidgetBackingStore()
{
+ for (int c = 0; c < dirtyWidgets.size(); ++c) {
+ resetWidget(dirtyWidgets.at(c));
+ }
+
delete windowSurface;
windowSurface = 0;
delete dirtyOnScreenWidgets;
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 4ddc6c4d1..e148fdbe8 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -67,6 +67,7 @@
#include <qcalendarwidget.h>
#include <qmainwindow.h>
#include <QtGui/qpaintengine.h>
+#include <private/qbackingstore_p.h>
#ifdef Q_WS_S60
#include <avkon.hrh> // EEikStatusPaneUidTitle
@@ -361,6 +362,8 @@ private slots:
void focusWidget_task254563();
+ void destroyBackingStore();
+
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -9199,5 +9202,31 @@ void tst_QWidget::focusWidget_task254563()
QVERIFY(top.focusWidget() != widget); //dangling pointer
}
+void tst_QWidget::destroyBackingStore()
+{
+ UpdateWidget w;
+ w.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&w);
+#endif
+ QApplication::processEvents();
+
+ w.reset();
+ w.update();
+ delete qt_widget_private(&w)->topData()->backingStore;
+ qt_widget_private(&w)->topData()->backingStore = 0;
+ qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w);
+
+ w.update();
+ QApplication::processEvents();
+ QCOMPARE(w.numPaintEvents, 1);
+
+ // Check one more time, because the second time around does more caching.
+ w.update();
+ QApplication::processEvents();
+ QCOMPARE(w.numPaintEvents, 2);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"